package es.uclm.itsue.dosd;

import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RectShape;
import android.os.Bundle;
import android.view.animation.AnimationSet;
import android.view.animation.RotateAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

public class TweenedAnimationsActivity extends Activity {
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.anim_views_layout);

	    ShapeDrawable box = new ShapeDrawable(new RectShape());
		box.getPaint().setColor(Color.CYAN);
		box.setBounds(50, 50, 100, 100);	
		
		ImageView iv = (ImageView) findViewById(R.id.img);
		iv.setBackgroundDrawable(box);
		
		RotateAnimation animRot = new RotateAnimation(
				0, 360, 
				RotateAnimation.RELATIVE_TO_SELF, 0.5f, 
				RotateAnimation.RELATIVE_TO_SELF, 0.5f);
		animRot.setDuration(5000);
		//iv.startAnimation(animRot);

		TranslateAnimation animTrans = new TranslateAnimation(
				200, 200, 200, 500);
		animTrans.setDuration(4000);
		//iv.startAnimation(animTrans);

		AnimationSet animSet = new AnimationSet(false);
		animSet.addAnimation(animRot);
		animSet.addAnimation(animTrans);
		iv.startAnimation(animSet);		
		
	}

}




